package com.magnificent.atlantis.client.ui.creator.tasktreetable.renderers;

import com.magnificent.atlantis.client.ui.creator.tasktreetable.data.CreatorTableNode;

import javax.swing.*;
import javax.swing.tree.DefaultTreeCellRenderer;
import java.awt.*;

/**
 * User: Babanin
 * Date: 27.12.2008
 * Time: 11:11:34
 * <p/>
 * Feci quod potui, faciant meliora potentes.
 */
public class CreatorTreeCellRenderer extends DefaultTreeCellRenderer {
    public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
        CreatorTableNode tableNode = (CreatorTableNode) value;
        JLabel label = (JLabel) super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);

        if (tableNode.getTask() != null) {
            label.setText(tableNode.getTask().getName());
            RendererHelper.updateColor(sel, tableNode, label);
        }
        
        return label;
    }


}
